﻿using System;
using System.Data.SqlClient;
using System.Runtime.Serialization;

namespace BikeBouncer.BusinessLayer.Entities
{
	[DataContract, Serializable]
	public class UserHistoryCollection : BaseCollection<UserHistory>
	{
		#region Constructor

		public UserHistoryCollection()
		{
		}

		public UserHistoryCollection(SqlDataReader reader)
		{
			Load(reader);
		}

        #endregion

		#region Loading

		public override sealed void Load(SqlDataReader reader)
		{
			if (Count > 0)
			{
				Clear();
			}

			while (reader.Read())
			{
				UserHistory uh = new UserHistory();
				uh.Load(reader);

				Add(uh);
			}

			if (!reader.IsClosed)
			{
				reader.Close();
			}

			reader.Dispose();
		}

		#endregion
	}
}